package com.haiya.iterator.conceptdemo;

public class Client {
    public static void main(String[] args) {
        ConcreteAggregate aggregate = new ConcreteAggregate();
        aggregate.add("张三");
        aggregate.add("李四");
        aggregate.add("王五");
        aggregate.add("小明");

        Iterator iterator = aggregate.getIterator();

        System.out.print("聚合内容:");
        while(iterator.hasNext()) {
            System.out.print(" " + iterator.next());
        }
        System.out.print("\n");

        System.out.println("第一个元素:" + iterator.first());
    }
}
